<template>
<wv-button type="primary" @click="atOnceOrder">立即下单</wv-button>
</template>

<script>
import { Button } from 'we-vue'
import axios from 'axios'
export default {
  name: 'OrderBtn',
  components: {
    Button
  },
  methods: {
    atOnceOrder () {
      console.log('立即下单')
      axios({
        url: 'http://114.115.216.44:8080/easy/es/order/create',
        method: 'post',
        data: {
          sendAddr: 'sendAddr',
          receiveAddr: 'receiveAddr',
          deliveryMode: 'deliveryMode',
          pickTime: '2018-1-1 11:11:11',
          goodValue: '11',
          goodWeight: '5',
          goodType: 'goodType',
          goodDesc: 'goodDesc',
          goodImgBase: 'goodImgBase',
          openId: 'openId',
          orderAmount: '11'
        },
        transformRequest: [function (data) {
          // Do whatever you want to transform the data
          let ret = ''
          for (let it in data) {
            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
          }
          return ret
        }],
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then(function (response) {
        console.log(response)
      })
        .catch(function (error) {
          console.log(error)
        })
    }
  }
}
</script>

<style>

</style>
